package com.ruoyi.fin.domain;

import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 财务交易记录对象 fin_transaction
 * 
 * @author ruoyi
 * @date 2025-06-19
 */
public class FinTransaction extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /**  */
    private Long id;

    /** 交易编号 */
    @Excel(name = "交易编号")
    private String transactionNo;

    /** 账户ID */
    @Excel(name = "账户ID")
    private Long accountId;

    /** 交易金额（正数为收入，负数为支出） */
    @Excel(name = "交易金额", readConverterExp = "正=数为收入，负数为支出")
    private BigDecimal amount;

    /** 类型（1:收入 2:支出） */
    @Excel(name = "类型", readConverterExp = "1=:收入,2=:支出")
    private Long type;
    
    /** 交易类型（0:收入 1:支出）- 字符串表示，适配事件系统 */
    private String transactionType;

    /** 交易类别 */
    @Excel(name = "交易类别")
    private String category;

    /** 交易日期 */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "交易日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date transactionDate;

    /** 交易描述 */
    @Excel(name = "交易描述")
    private String description;

    /** 来源类型（purchase:采购 sales:销售 manual:手工） */
    @Excel(name = "来源类型", readConverterExp = "p=urchase:采购,s=ales:销售,m=anual:手工")
    private String sourceType;

    /** 来源ID */
    @Excel(name = "来源ID")
    private Long sourceId;
    
    /** 来源编码 */
    private String sourceCode;
    
    /** 交易状态（0-待处理 1-已处理）*/
    private String transactionStatus;
    
    /** 备注 */
    private String remark;

    /** 创建人ID */
    @Excel(name = "创建人ID")
    private Long createdBy;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date createdAt;

    /** 更新时间 */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date updatedAt;

    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }

    public void setTransactionNo(String transactionNo) 
    {
        this.transactionNo = transactionNo;
    }

    public String getTransactionNo() 
    {
        return transactionNo;
    }

    public void setAccountId(Long accountId) 
    {
        this.accountId = accountId;
    }

    public Long getAccountId() 
    {
        return accountId;
    }

    public void setAmount(BigDecimal amount) 
    {
        this.amount = amount;
    }
    
    public void setAmount(Double amount) 
    {
        this.amount = BigDecimal.valueOf(amount);
    }

    public BigDecimal getAmount() 
    {
        return amount;
    }

    public void setType(Long type) 
    {
        this.type = type;
    }

    public Long getType() 
    {
        return type;
    }
    
    public void setTransactionType(String transactionType) 
    {
        this.transactionType = transactionType;
        // 同步设置type字段
        if ("0".equals(transactionType)) {
            this.type = 1L; // 收入
        } else if ("1".equals(transactionType)) {
            this.type = 2L; // 支出
        }
    }

    public String getTransactionType() 
    {
        return transactionType;
    }

    public void setCategory(String category) 
    {
        this.category = category;
    }

    public String getCategory() 
    {
        return category;
    }

    public void setTransactionDate(Date transactionDate) 
    {
        this.transactionDate = transactionDate;
    }

    public Date getTransactionDate() 
    {
        return transactionDate;
    }

    public void setDescription(String description) 
    {
        this.description = description;
    }

    public String getDescription() 
    {
        return description;
    }

    public void setSourceType(String sourceType) 
    {
        this.sourceType = sourceType;
    }

    public String getSourceType() 
    {
        return sourceType;
    }

    public void setSourceId(Long sourceId) 
    {
        this.sourceId = sourceId;
    }

    public Long getSourceId() 
    {
        return sourceId;
    }
    
    public void setSourceCode(String sourceCode) 
    {
        this.sourceCode = sourceCode;
    }

    public String getSourceCode() 
    {
        return sourceCode;
    }
    
    public void setTransactionStatus(String transactionStatus) 
    {
        this.transactionStatus = transactionStatus;
    }

    public String getTransactionStatus() 
    {
        return transactionStatus;
    }
    
    @Override
    public String getRemark() 
    {
        return remark;
    }

    @Override
    public void setRemark(String remark) 
    {
        this.remark = remark;
    }

    public void setCreatedBy(Long createdBy) 
    {
        this.createdBy = createdBy;
    }

    public Long getCreatedBy() 
    {
        return createdBy;
    }

    public void setCreatedAt(Date createdAt) 
    {
        this.createdAt = createdAt;
    }

    public Date getCreatedAt() 
    {
        return createdAt;
    }

    public void setUpdatedAt(Date updatedAt) 
    {
        this.updatedAt = updatedAt;
    }

    public Date getUpdatedAt() 
    {
        return updatedAt;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("transactionNo", getTransactionNo())
            .append("accountId", getAccountId())
            .append("amount", getAmount())
            .append("type", getType())
            .append("transactionType", getTransactionType())
            .append("category", getCategory())
            .append("transactionDate", getTransactionDate())
            .append("description", getDescription())
            .append("sourceType", getSourceType())
            .append("sourceId", getSourceId())
            .append("sourceCode", getSourceCode())
            .append("transactionStatus", getTransactionStatus())
            .append("remark", getRemark())
            .append("createdBy", getCreatedBy())
            .append("createdAt", getCreatedAt())
            .append("updatedAt", getUpdatedAt())
            .toString();
    }
}
